﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter11.Code01.Code05
{
    using System.Collections;

    public class Demo
    {
        public static void Begin()
        {
            //{
            //    Animals animalCollection = new Animals();
            //    animalCollection.Add("Jack", new Cow("Jack"));
            //    animalCollection.Add("Vear", new Chicken("Vear"));
            //    foreach (Animal myAnimal in animalCollection)
            //    {
            //        Console.WriteLine("New {0} object added to ArrayList collection, Name = {1}", myAnimal.ToString(), myAnimal.Name);
            //    }
            //    Console.ReadLine();
            //}
            {
                Animals animalCollection = new Animals();
                animalCollection.Add("Jack", new Cow("Jack"));
                animalCollection.Add("Vear", new Chicken("Vear"));
                foreach (DictionaryEntry myEntry in (DictionaryBase)animalCollection)
                {
                    Console.WriteLine("New {0} object added to ArrayList collection, Name = {1}", myEntry.Value.ToString(), ((Animal)myEntry.Value).Name);
                }
                Console.ReadLine();
            }
        }
    }
}
